from django.urls import path, include
from sa.views import account, home, customer, my_project, project_manage, center
from django.contrib import admin

urlpatterns = [
    # path('admin/', admin.site.urls),
    # 登录
    path('image/code/', account.image_code, name='image_code'),
    path('login/', account.user_login, name='user_login'),
    path('logout/', account.user_logout, name='user_logout'),
    path('change/pwd/', account.change_pwd, name='change_pwd'),

    # index首页
    path('index/', home.index, name='index'),
    path('', home.index, name='index'),
    path('index/bar/', home.chart_bar, name='chart_bar'),
    path('index/pie/', home.chart_pie, name='chart_pie'),
    path('index/line/', home.chart_line, name='chart_line'),

    # 客户路由
    path('customer/', customer.customer_list, name='customer_list'),
    path('customer/<int:c_id>/detail/', customer.customer_detail, name='customer_detail'),
    path('customer/addproject/', customer.add_project, name='customer_add_project'),

    # 项目路由
    path('myproject/list/', my_project.project_list, name='my_project_list'),
    path('search/', my_project.search_view, name='search'),
    # 根据 search 内容，拿到对象
    path('search/data/', my_project.search_data, name='search_data'),

    # 项目管理 每个项目下包含一个或多个task
    # <int:p_id>, <int:t_id>
    path('project/<int:p_id>/', include([
        path('manage/', project_manage.project_view, name='project_view'),
        path('delete/', project_manage.project_delete, name='project_delete'),

        path('task/add/', project_manage.task_add, name='task_add'),
        path('task/catalog/', project_manage.task_catalog, name='task_catalog'),
        path('task/<int:t_id>/edit/', project_manage.task_edit, name='task_edit'),
        path('task/<int:t_id>/delete/', project_manage.task_delete, name='task_delete'),
    ])),

    # 项目中心
    path('center/', center.platform, name='center_platform'),
    path('center/export_project', center.export_project, name='export_project'),
    path('center/<int:p_id>/project/', center.project_info, name='project_info'),
    path('center/<int:p_id>/project/tasklist/', center.tasklist, name='tasklist'),


]
